<template>
  <div>
    <div class="box">
      <p v-for="(item, index) in arr" :key="index">
        <!-- 加类名要加 ：  -->
        <input type="checkbox" :value="item" v-model="newArr"><span>{{ item }}</span>
      </p>
    </div>
    <p>您选中的元素，累加值为：{{ res() }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
      newArr: []
    }
  },
  methods: {
    res() {
     return this.newArr.reduce((sum, val)=>sum +=val,0)
    }
  }
}
</script>

<style scoped>
.box {
  display: flex;
}
</style>
